const path = require('path');
const args = require('minimist')(process.argv.slice(2));
const Env = process.env; //window环境变量不区分大小写;

const rootPath = path.resolve(__dirname, '../../'); //项目根目录
const srcPath = path.resolve(rootPath, Env.srcPath || 'src'); //源码目录 相对于rootPath,生成的绝对路径
const distPath = path.resolve(rootPath, Env.distPath || 'dist'); //输出目录

const devPort =  Env.port || 23456;//开发模式
const port = devPort;

//web根路径，影响所有静态资源的指向,可以相对于域名，也可以写死域名
const publicPath = args.env&&args.env==='dist'?(Env.publicPath || '/youjia_qnui/dist/'):`http://127.0.0.1:${devPort}/`;
const mainJsName = 'app';//主入口生成的文件名
const reactLibraryName =  'ReactFamily';//react相关的包名
const HtmlPluginConfig = { //html-webpack-plugin的配置
  alwaysWriteToDisk: true, //总是创建html文件 仅当引入HtmlWebpackHarddiskPlugin时有效
  filename: 'index.html',
  favicon: `${srcPath}/favicon.ico`,
  template: `${srcPath}/index_${args.env==='dist'?'dist':'dev'}.html`//html模板
};

module.exports = {
  rootPath,
  srcPath,
  distPath,
  devPort,
  port,
  publicPath,
  mainJsName,
  reactLibraryName,
  HtmlPluginConfig
};
